package com.example.recordingpen_datacollection.controller;


import com.example.recordingpen_datacollection.entity.Query.LogendtimeviewQue;
import com.example.recordingpen_datacollection.entity.Query.LogquotaviewQue;
import com.example.recordingpen_datacollection.redisService.RedisService;
import com.example.recordingpen_datacollection.result.RLIST;
import com.example.recordingpen_datacollection.service.LogendtimeviewService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xg
 * @since 2024-06-13
 */
@Api(tags = "时间设置日志")
@RestController
@RequestMapping("/logendtimeview")
public class LogendtimeviewController {
    @Autowired
    private LogendtimeviewService logendtimeviewService;
    @Autowired
    private RedisService redisService;

    @ApiOperation(value = "查询时间日志")
    @PostMapping("/getview")
    public RLIST getLogquota(@RequestBody LogendtimeviewQue logendtimeviewQue, HttpServletRequest request){
        String token = request.getHeader("token");
        if( !(token.length() == 51 || token.length() == 56) ){
            return RLIST.error().message("无权操作");
        }
        Integer value = null;
        if (token.length() == 51) {
            value = (Integer) redisService.getValue(token);
        }
        RLIST rlist = logendtimeviewService.getlogendtimePage(logendtimeviewQue,value);
        return rlist;
    }

}

